
register_crad_rule('加百列',{'忠诚','节制','慷慨','希望','坚韧','宽容','正义'})
register_crad_rule('路西法',{'懒惰','贪婪','暴食','色欲','傲慢','嫉妒','暴怒'})

local cards = {'懒惰','贪婪','暴食','色欲','傲慢','嫉妒','暴怒','忠诚','节制','慷慨','希望','坚韧','宽容','正义',}

local mt = ac.skill['降临']
function mt:on_add()
    local hero = self.owner
    local player = hero.owner
    local Lock = player:get_data('无法获得卡') or {}
    
    self.timer_count = ac.loop(self.data1*1000,function()
        local info = {}
        for i,name in ipairs(cards) do
            local data = get_card_data(name)
            if Lock[name]==nil then
                table.insert(info,data)
            end
        end
        info = table.random_table(info,1)
        if #info>0 then
            player:set_data('当前额外卡组',info)
            player:notify('卡池-显示抽卡',player,info)
        end
    end)
    self:gc(self.timer_count)

    if hero[self.name] then
        return
    end
    hero[self.name] = true
    for _,name in ipairs(cards) do
        player:set_data(name,true)
    end

    local add_pool = {}
    hero:event '英雄-失去天赋'(function(_,_,temp)
        if table.find(cards,temp.name) then
            if not table.find(add_pool,temp.name) then
                table.insert(add_pool,temp.name)
            end
        end
    end)
    player:event '卡池-添加卡组'(function(_,_,pool)
        for _,name in ipairs(add_pool) do
            pool[#pool+1] = name
        end
    end)
    

end



local mt = ac.skill['罪之舞']

function mt:on_add()
    local hero = self.owner
    self:gc(hero:add_buff '罪之舞'{skill = self,pulse = self.data1})
end

local mt = ac.buff['罪之舞']
mt.cover_max = 1
mt.cover_type = 1
mt.pulse = 1
mt.model1 = [[7dfa658ff5b6bc4bb46432aced9b8ffe.mdl]]
function mt:on_pulse()
    local hero = self.owner
    local skill = self.skill
    local damage = hero:get('全属性') * skill.data2 / 100 * (1 + hero:get_data('七原罪-计数',0) * skill.data3/100)
    local start = hero:get_point()
    for a=1,6 do
        ac.mover('line'){
            start = start,
            angle = a*60,
            model = self.model1,
            speed = 1200,
            distance = 700,
        }
    end
    hero:diffuse_damage(start,700,1200){
        damage_type = '魔法',
        damage = damage,
        skill = skill,
    }
end


local mt = ac.skill['永恒沉沦']
function mt:on_add()
    local hero = self.owner
    self:gc(hero:add_buff '永恒沉沦'{skill = self})
end


local mt = ac.buff['永恒沉沦']
mt.cover_max = 1
mt.cover_type = 1
mt.model1 = [[87a4ea1166e10a290dbe4bda3f0fa118.mdl]]
function mt:on_add()
    local hero = self.owner
    local skill = self.skill
    local count = 0
    self:gc(hero:event '单位-攻击命中'(function(_,_,target)
        count = count + 1
        if count>=skill.data1 then
            local damage = hero:get('全属性') * skill.data2 / 100
            local start = hero:get_point()
            local angle = hero:get_facing()
            count = 0
            for a=-1,1 do
                ac.mover('line'){
                    start = start,
                    angle = angle + a*30,
                    model = self.model1,
                    speed = 1800,
                    distance = 800,
                }
            end
            ac.wait(0.4,function()
                for u in ac.selector('unit')
                    : sector(start,800,angle,60)
                    : enemy(hero)
                    : loop()
                do
                    hero:create_damage(u,damage,skill)
                end
            end)
            
        end
    end))
end


local mt = ac.skill['光辉']

function mt:open()
    local hero = self.owner
    if self.removed==nil then
        local heal = hero:get('全属性') * self.data2 / 100
        hero:add('生命',heal)
        self:on_add()
    end
end

function mt:on_add()
    local hero = self.owner
    local time = self.data1 - hero:get_data('七美德-计数',0) * self.data3 
    ac.wait(time*1000,function()
        self:open()
    end)
end


local mt = ac.skill['新生']
function mt:on_add()
    local hero = self.owner
    self:gc(ac.game:event '玩家-新的一天'(function()
        hero:add('全属性',self.data1)
    end))
end